var fs = require("fs");
var sliderConfig = JSON.parse(fs.readFileSync("public/javascripts/widget/slider/sliderConfig.json"));
var seoData = null;
function clone(obj){
    var o;
    if(typeof obj == "object"){
        if(obj === null){
            o = null;
        }else{
            if(obj instanceof Array){
                o = [];
                for(var i = 0, len = obj.length; i < len; i++){
                    o.push(clone(obj[i]));
                }
            }else{
                o = {};
                for(var k in obj){
                    o[k] = clone(obj[k]);
                }
            }
        }
    }else{
        o = obj;
    }
    return o;
}
var Tools = {
    getPageSliderData: function(pageName) {
        var sliderData = clone(sliderConfig[pageName]);
        return sliderData;
    },
    getSeoData:function (urlName, callback) {
        fs.readFile("public/common/seo.json", function(err, data) {
            data = JSON.parse(data.toString());
            callback(data[urlName] ? data[urlName] : {});
        });
    }
}
module.exports = Tools;